Make Garmin smartname code handle name and commment a little more independently,...
authorrobertl <robertl>
Thu, 3 Jan 2008 17:47:38 +0000 (17:47 +0000)
committerrobertl <robertl>
Thu, 3 Jan 2008 17:47:38 +0000 (17:47 +0000)
garmin.c

index 57070d968d5d65af262f53453a2cfb652d11f957..a06ca796ac86e9f177706186468b4cc51fb7cfbc 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -732,19 +732,27 @@ waypoint_write(void)
                }
                way[i]->ident[sizeof(way[i]->ident)-1] = 0;
 
-               if (global_opts.smart_names && 
-                    wpt->gc_data.diff && wpt->gc_data.terr) {
+               // If we were explictly given a comment from GPX, use that. 
+               if (wpt->description) {
+                       memcpy(way[i]->cmnt, wpt->description, strlen(wpt->description));
+               } else {
+                       if (global_opts.smart_names && 
+                            wpt->gc_data.diff && wpt->gc_data.terr) {
 #if 0
 xasprintf(&src, "%s %s", &wpt->shortname[2], src);
 #endif
-                       snprintf(obuf, sizeof(obuf), "%s%d/%d %s", 
-                                       get_gc_info(wpt),
-                                       wpt->gc_data.diff, wpt->gc_data.terr, 
-                                       src);
-                       memcpy(way[i]->cmnt, obuf, strlen(obuf));
-               } else  {
-                       memcpy(way[i]->cmnt, src, strlen(src));
+                               snprintf(obuf, sizeof(obuf), "%s%d/%d %s", 
+                                               get_gc_info(wpt),
+                                               wpt->gc_data.diff, wpt->gc_data.terr, 
+                                               src);
+                               memcpy(way[i]->cmnt, obuf, strlen(obuf));
+                       } else  {
+                               memcpy(way[i]->cmnt, src, strlen(src));
+                       }
                }
+
+               
+
                way[i]->lon = wpt->longitude;
                way[i]->lat = wpt->latitude;